<template>
  <div class="price sortPage">
    <pricebar @showbar="tardeNumset" :tardeNum="tardeNum"></pricebar>
     <van-sticky v-show="tardeNum==1" :offset-top="46">
      <coll-dom :arr="arr"></coll-dom>
    </van-sticky>
    <price-list  v-if="tardeNum==1"></price-list>
    <priceselfList v-if="tardeNum==0"></priceselfList>
  </div>
</template>

<script type="text/ecmascript-6">
import collDom from "../../components/price/collapse";
import priceList from "../../components/price/priceList";
import priceselfList from "../../components/price/priceselfList";
import pricebar from "../../components/nav/pricebar.vue";
import { newsTitle } from "../../assets/data/menuData.js";
export default {
  components: {
    collDom,
    priceList,
    pricebar,
    priceselfList
  },
  data() {
    return {
      tardeNum: "",
      arr: [
        { text: newsTitle.dc.title, id: "dc" },
        { text: newsTitle.tcl.title, id: "tcl" },
        { text: newsTitle.dlg.title, id: "dlg" }
      ]
    };
  },

  methods: {
    tardeNumset(i) {
      this.tardeNum = i;
      if (i == 1) {
        document.getElementsByClassName(
          "van-sticky"
        )[0].parentNode.style.height = "46px";
        document.getElementsByClassName(
          "van-sticky"
        )[1].parentNode.style.height = "46px";
      }
    },
    judge() {
      let islogin = this.$store.state.islogin;
      if (islogin) {
        let obj = this.$store.state.loginInforXl;
        let channel = this.$store.state.nocaches.pricepartObj.channel;
        if (channel == "tcl" && obj.is_ts=="1") { 
          this.myprice = obj.tcl_myprice;
        }else if (channel == "tcl" && obj.is_ts=="0") { 
          this.myprice =[] 
        } else if (channel == "dc" && obj.is_dc=="1") {
          this.myprice = obj.dc_myprice;
        }else if (channel == "dc" && obj.is_dc=="0") {
          this.myprice = [] 
        } else if (channel == "dlg" && obj.is_gt=="1") {
          this.myprice = obj.dlg_myprice;
        }else if (channel == "dc" && obj.is_gt=="0") {
          this.myprice = [] 
        }
         
        if (this.myprice.length > 0) {
          this.tardeNum = 0;
        } else {
          this.tardeNum = 1;
        }
      } else {
        this.tardeNum = 1;
      }
    }
  },
  created() {
    this.judge();
  },
   activated () {
     //從側邊欄进来的页面要判断一下
    if ( window.localStorage.getItem("origin")=="person") {   
        window.localStorage.setItem("origin", "");
         this.judge(); 
    }  
  }
};
</script>
<style scoped lang="less">
.price {
  width: 100%;
  min-height: 100%;
  background: #ffffff;
}

.van-dropdown-menu {
  height: 0.88rem;
}
 
</style>
